package com.qf.service.impl;

import com.qf.entity.DataDictionary;
import com.qf.mapper.DataDictionaryMapper;
import com.qf.service.DataDictionaryService;
import com.qf.vo.DataDictionaryVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Service
public class DataDictionaryServiceImpl implements DataDictionaryService {

    @Autowired
    private DataDictionaryMapper dataDictionaryMapper;

    @Override
    public List<DataDictionaryVO> findValueByType(String code) {

        DataDictionary dataDictionary = new DataDictionary();
        dataDictionary.setTypeCode(code);

        List<DataDictionary> list = dataDictionaryMapper.select(dataDictionary);

        List<DataDictionaryVO> dataDictionaryVOList = new ArrayList<>();
        for (DataDictionary dictionary : list) {
            dataDictionaryVOList.add(new DataDictionaryVO(dictionary.getValueId(),dictionary.getValueName()));
        }

        return dataDictionaryVOList;
    }
}
